#include "Vertex.h"
#include "util/ByIdMatcher.h"

Edge::Edge(std::string id, Vertex* origin, Vertex* destination,
		double distanceInMeters, double speedInKMH) {
	this->setId(id);
	this->setOrigin(origin);
	this->getOrigin()->addOutgoingEdge(this);
	this->setDestination(destination);
	this->setDistanceInMeters(distanceInMeters);
	this->setSpeedInKMH(speedInKMH);
}

Edge::~Edge() {
	this->getOrigin()->removeOutgoingEdge(this);
}

bool Edge::equals(Edge* other) {
	ByIdMatcher<Edge> matcher(this);
	return matcher.matches(other);
}

std::string Edge::getId() {
	return this->id;
}

Vertex* Edge::getOrigin() {
	return this->origin;
}

Vertex* Edge::getDestination() {
	return this->destination;
}

double Edge::getDistanceInMeters() {
	return this->distanceInMeters;
}

double Edge::getSpeedInKMH() {
	return this->speedInKMH;
}

void Edge::setId(std::string id) {
	this->id = id;
}

void Edge::setOrigin(Vertex* origin) {
	this->origin = origin;
}

void Edge::setDestination(Vertex* destination) {
	this->destination = destination;
}

void Edge::setDistanceInMeters(double distance) {
	this->distanceInMeters = distance;
}

void Edge::setSpeedInKMH(double speed) {
	this->speedInKMH = speed;
}

bool Edge::operator==(const Edge &other) {
	return this->id == other.id;
}
